#ifndef HB_SIFTAPI_H
#define HB_SIFTAPI_H


#include <iostream>
#include <fstream>
#include <chrono>
#include <algorithm>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#ifdef PLATFORM_ARCH_x86_64
#include <opencv2/xfeatures2d/xfeatures2d.hpp>
#else
//sunrise x3
#include <opencv2/xfeatures2d.hpp>
#endif

enum QrCodeType{
	AllQrCode = 0,
	ExternalQrCode = 1,
	InternalQrCode = 2
};

/*
** function: get sift keypoints and descriptor
** _imGray: source  gray image
** _kp: keypoints
** _des: descriptor
** bool: return true indicates the function is ok, if false not ok
*/
bool siftHandleImage(const cv::Mat &imGray, std::vector<cv::KeyPoint> &kp, cv::Mat &des);


/*
** function: compute homography
**	_matches: BruteForce matches
** _soureKp: source keypoints
** _targetKp: target keypoints
** _goodMatchesNum :  minimum number of good matches
** _rationAngle: return the ration angle from the homography
** bool: return true indicates the function is ok, if false not ok
*/
bool computeH(std::vector<cv::DMatch> &matches, std::vector<cv::KeyPoint> &soureKp,
						std::vector<cv::KeyPoint> &targetKp, int &goodMatchesNum,double &rationAngle, int &returnGoodMatchesNum);




/*
** function :compute Landing position
** imGray: compare image gray data
** markerExKp: marker exteral image keypoints
** markerExDes: marker exteral image keypoints descriptor
** markerInKp: marker interal image keypoints
** markerInDes: marker interal image keypoints descriptor
** Rect: return check rect four corne point, and the five point is center point of rect
** rationAngle: return the ration angle of the imGray
** inOrEx: 1 indicates exteral, 2 indicates interal
** bool: return ture indicates the check land postion is ok, false is not.
*/
bool computeLandPosition(const cv::Mat &imGray, std::vector<cv::KeyPoint> &markerExKp, cv::Mat &markerExDes,
						std::vector<cv::KeyPoint> &markerInKp, cv::Mat &markerInDes, std::vector<cv::Point> &rect, double &rationAngle,
						int &inOrEx, int &externalGoodMatchesMinNum, int &internalGoodMatchesMinNum, int &returnGoodMatchesNum, bool camerIsFlat = true);



#endif  //HB_SIFTAPI_H

